﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ZYPPC6
{
    public partial class Form6YaoNew : Form
    {
        private ZYOPPC.控件.摇卦控件[] 摇卦控件s;

        public Form6YaoNew()
        {
            InitializeComponent();

            摇卦控件s = new ZYOPPC.控件.摇卦控件[6] { 摇卦控件1, 摇卦控件2, 摇卦控件3, 摇卦控件4, 摇卦控件5, 摇卦控件6 };
        }

        private void menuItemOK_Click(object sender, EventArgs e)
        {
            Form六爻起卦 form6Yao = new Form六爻起卦();

            switch (tabControl1.SelectedIndex)
            {

                case 0: // 摇卦

                    String GuaString = String.Empty;
                    foreach (ZYOPPC.控件.摇卦控件 YaoCtrl in 摇卦控件s)
                    {
                        GuaString += YaoCtrl.Value.ToString();
                    }

                    form6Yao.卦 = new ZYOPPC.class六爻起卦(ZYOPPC.ZYOEnum.e起卦方法.摇卦,
                                                         DateTime.Now, GuaString, comboBoxAsk.SelectedText,
                                                         textBoxRequester.Text.Trim());
                    break;


                case 1: // 测字   [文字]可以以 ；分开

                    try 
                    {
                        // Both of String are number
                        int iup = int.Parse(this.textBoxUp.Text);
                        int idown = int.Parse(this.textBoxDown.Text);
                        form6Yao.卦 = new ZYOPPC.class六爻起卦(ZYOPPC.ZYOEnum.e起卦方法.数字,
                                     DateTime.Now,
                                     iup.ToString() + ';' + idown.ToString(),
                                     comboBoxAsk.SelectedText,
                                     textBoxRequester.Text.Trim());

                    }
                    catch 
                    {
                        // input string is not number
                        form6Yao.卦 = new ZYOPPC.class六爻起卦(ZYOPPC.ZYOEnum.e起卦方法.测字,
                                                             DateTime.Now,
                                                             this.textBoxUp.Text + ';' + this.textBoxDown.Text,
                                                             comboBoxAsk.SelectedText,
                                                             textBoxRequester.Text.Trim());
                    }

                    break;

                case 2: // 时间
                    form6Yao.卦 = new ZYOPPC.class六爻起卦(ZYOPPC.ZYOEnum.e起卦方法.时间,
                                                             dtPicker.Value,
                                                             String.Empty,
                                                             comboBoxAsk.SelectedText,
                                                             textBoxRequester.Text.Trim());

                    break;


            }

            form6Yao.ShowDialog();
        }

        private void menuItemQuit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Form6YaoNew_Load(object sender, EventArgs e)
        {
            dtPicker.Value = DateTime.Now;
            comboBoxAsk.SelectedIndex = 0;
        }
    }
}